<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <h1>{{msg}}</h1>
        <com1></com1>
        <com2></com2>
    </div>
    <script src="./js/vue.js"></script>
    <script>
        Vue.component("com1", {
            data() {
                return {
                    msg: "com1",
                    count: 0
                }
            },
            template: `<div>
                {{msg}}
                {{count}}
                <button @click="add">点击++</button>
            </div>`,
            methods: {
                add() {
                    this.count++;
                }
            }
        })
        Vue.component("com2", {
            data() {
                return {
                    msg: "com2",
                    count: 0
                }
            },
            template: `<div>
                {{msg}}
                {{count}}
                <button @click="add">点击++</button>
            </div>`,
            methods: {
                add() {
                    this.count++;
                }
            }
        })
        let vm = new Vue({
            el: '#app',
            data: {
                msg: "Hello Vue"
            },
            methods: {}
        });
    </script>
</body>

</html>